import request from '../request'

// Dashboard统计接口
export const dashboardApi = {
    getStatistics: () => request.get('/admin/dashboard/statistics')
}

// 员工管理 - 严格对应 AdminController
export const employeeApi = {
    login: (data) => request.post('/admin/employee/login', data),
    register: (data) => request.post('/admin/employee/register', data),
    getById: (id) => request.get(`/admin/employee/${id}`),
    update: (data) => request.put('/admin/employee', data),
    updateStatus: (status, id) => request.post(`/admin/employee/status/${status}?id=${id}`),
    // 新增分页查询接口
    page: (params) => request.get('/admin/employee/page', { params })
}


// 药材分类管理 - 严格对应 HerbCateryController
export const herbCategoryApi = {
    add: (data) => request.post('/admin/herb-category', data),
    delete: (id) => request.delete(`/admin/herb-category/${id}`),
    update: (data) => request.put('/admin/herb-category', data),
    getById: (id) => request.get(`/admin/herb-category/${id}`),
    page: (categoryName, page, pageSize) => request.get('/admin/herb-category/page', {
        params: { categoryName, page, pageSize }
    }),
    getTree: () => request.get('/admin/herb-category/tree')
}

// 中药材管理 - 严格对应 ChineseHerbController
export const chineseHerbApi = {
    add: (data) => request.post('/admin/chinese-herb', data),
    delete: (id) => request.delete(`/admin/chinese-herb/${id}`),
    update: (data) => request.put('/admin/chinese-herb', data),
    getById: (id) => request.get(`/admin/chinese-herb/${id}`),
    page: (herbName, categoryId, page, pageSize) => request.get('/admin/chinese-herb/page', {
        params: { herbName, categoryId, page, pageSize }
    }),
    search: (keyword) => request.get('/admin/chinese-herb/search', { params: { keyword } }),
    updateStatus: (status, id) => request.post(`/admin/chinese-herb/status/${status}?id=${id}`)
}

// 药材库存管理 - 严格对应 HerbInventoryController
export const herbInventoryApi = {
    add: (data) => request.post('/admin/herb-inventory', data),
    update: (data) => request.put('/admin/herb-inventory', data),
    delete: (id) => request.delete(`/admin/herb-inventory/${id}`),
    getById: (id) => request.get(`/admin/herb-inventory/${id}`),
    page: (herbId, batchNumber, page, pageSize) => request.get('/admin/herb-inventory/page', {
        params: { herbId, batchNumber, page, pageSize }
    }),
    getWarningList: () => request.get('/admin/herb-inventory/warning'),
    getExpiringList: () => request.get('/admin/herb-inventory/expiring')
}
